import React, {Component} from 'react'
import {CSSTransition} from 'react-transition-group'
export default (Comp) => {
    return class extends Component{
        render() {
            let value = this.props.location.state ? this.props.location.state.value : 'left';
            return (
                <CSSTransition
                    in={!!this.props.match}
                    classNames={{
                        enter:'animated',
                        enterActive:value === 'right' ? 'fadeInRight' : 'fadeInLeft',
                        exit:'animated',
                        exitActive:value === 'right' ? 'fadeOutLeft' : 'fadeOutRight'
                    }}
                    mountOnEnter={true}
                    unmountOnExit={true}
                    timeout={500}
                >
                    <Comp {...this.props}/>
                </CSSTransition>
            )
        }
    }
}
